The VDoc development kit provides a new Framework for implementing new functions used within the documents. This new Framework is very similar to both components and plug-in frameworks. It provides a Java-based plug-in model for functions.
To speed time to market and reduce costs for developers, this new Framework includes a complete API, libraries and samples that illustrate reference implementation for successful custom functions.
This topic provides information about VDoc development kit and how you can create custom functions to enhance your documents.
A function is a small unit of process which transforms data to a particular output. Functions are used in several contexts :
Basically, a function is composed of a name, arguments and a method called execute. The return type is a java.lang.Object.
The function Framework gives a standard way for defining :
The XML function file should be deployed on the custom/functions folder. Its name must be unique on the VDoc server. To prevent name conflicts it is recommended to use the following template: companyName-functions.xml (e.i. vdoc-functions.xml). This XML definition file provides all the necessary information to describe several functions:
Error during retrieving content skip as ignoreDownloadError activated.
A runtime class is a Java class which will be called by the framework. A runtime class must extend the Open Declaration com.axemble.vdoc.sdk.BaseFormulaFunction class.
By creating a function runtime class you need to implement a unique method: execute().
/** Example : */ public class TranslateFunction extends BaseFormulaFunction { private static final long serialVersionUID = 1L; public String execute( String id, String... args ) { String language = (String)getContextValue( "language" ); // retrieve the language return LocalizationMap.getString( id, language, args ); } }
In order to localize the name of the function, you should always specify each string as a resource. The XML resource file should be deployed on the custom/internationalization folder. Its name must be unique on the VDoc server. To prevent name conflicts it is recommended to use the following template: companyName-functions-resources.xml (e.i. vdoc-functions-resources.xml). This file must contain every string used for the treatment.
Use the ids as shown in the following exemple:
Error during retrieving content skip as ignoreDownloadError activated.
In order to define new categories, you can deploy an XML file on the custom/global folder. To prevent name conflicts it is recommended to use the following template: companyName-global.xml (e.i. vdoc-global.xml).
<definitions> <function> <categories> <category name="mycategory" label="formula.function.category.mycategory.label" description="formula.function.category.mycategory.description"/> </categories> </function> </definitions>